package com.ruoyi.asset.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.asset.domain.AstTaskUserList;
import com.ruoyi.asset.service.IAstTaskUserListService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 历史巡站Controller
 * 
 * @author xunzhe
 * @date 2024-12-06
 */
@Controller
@RequestMapping("/asset/taskUserList")
public class AstTaskUserListController extends BaseController
{
    private String prefix = "asset/taskUserList";

    @Autowired
    private IAstTaskUserListService astTaskUserListService;

    @RequiresPermissions("asset:taskUserList:view")
    @GetMapping()
    public String taskUserList()
    {
        return prefix + "/taskUserList";
    }

    /**
     * 查询历史巡站列表
     */
    @RequiresPermissions("asset:taskUserList:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AstTaskUserList astTaskUserList)
    {
        startPage();
        List<AstTaskUserList> list = astTaskUserListService.selectAstTaskUserListList(astTaskUserList);
        return getDataTable(list);
    }

    /**
     * 导出历史巡站列表
     */
    @RequiresPermissions("asset:taskUserList:export")
    @Log(title = "历史巡站", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AstTaskUserList astTaskUserList)
    {
        List<AstTaskUserList> list = astTaskUserListService.selectAstTaskUserListList(astTaskUserList);
        ExcelUtil<AstTaskUserList> util = new ExcelUtil<AstTaskUserList>(AstTaskUserList.class);
        return util.exportExcel(list, "历史巡站数据");
    }

    /**
     * 新增历史巡站
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存历史巡站
     */
    @RequiresPermissions("asset:taskUserList:add")
    @Log(title = "历史巡站", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AstTaskUserList astTaskUserList)
    {
        return toAjax(astTaskUserListService.insertAstTaskUserList(astTaskUserList));
    }

    /**
     * 修改历史巡站
     */
    @RequiresPermissions("asset:taskUserList:edit")
    @GetMapping("/edit/{listId}")
    public String edit(@PathVariable("listId") Long listId, ModelMap mmap)
    {
        AstTaskUserList astTaskUserList = astTaskUserListService.selectAstTaskUserListByListId(listId);
        mmap.put("astTaskUserList", astTaskUserList);
        return prefix + "/edit";
    }

    /**
     * 修改保存历史巡站
     */
    @RequiresPermissions("asset:taskUserList:edit")
    @Log(title = "历史巡站", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AstTaskUserList astTaskUserList)
    {
        return toAjax(astTaskUserListService.updateAstTaskUserList(astTaskUserList));
    }

    /**
     * 删除历史巡站
     */
    @RequiresPermissions("asset:taskUserList:remove")
    @Log(title = "历史巡站", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(astTaskUserListService.deleteAstTaskUserListByListIds(ids));
    }
}
